<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/**

 * Local Helper 

 *

 */
if ( ! function_exists('curPageName'))
{
	function curPageName() {
	 return substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);
	}
}
if ( ! function_exists('getCurrentMenu'))
{
	function getCurrentMenu($MenuName){
		$currentpage = $_SERVER["REQUEST_URI"];
		$_result="";
		$_pos=strpos($currentpage,$MenuName);
		if($_pos>-1){
			$_result="class=\"menuhover\"";			
		}
		return $_result;
	}
}
if ( ! function_exists('curPageURL'))
{
		function curPageURL() 
		{
			 $pageURL = 'http';
			 //if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
			 if (!empty($_SERVER['HTTPS'])) {$pageURL .= "s";}  
			 $pageURL .= "://";
			 if ($_SERVER["SERVER_PORT"] != "80") {
			  $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
			 } else {
			  $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
			 }
			 return $pageURL;
		}
}
 if ( ! function_exists('GetTrEffects'))
{
		function GetTrEffects() 
		{
		return " onmouseover='tr_onmouseover(this)' onmouseout='tr_onmouseout(this)' onclick='tr_onclick(this)' active='false' ";
		}
}
//eliminate *.php filename
if ( ! function_exists('my_url'))
{
	function my_url($uri = '')
	{
		$CI =& get_instance();
		$_url = $CI->config->base_url($uri);		
		if (strpos($_url,".")>0){
			$l_phpname_count=  strpos(strrev($_url),"/",1);
			return substr($_url,0,strlen($_url) -$l_phpname_count );			
	}
		return $_url;
	}
}
//eliminate *.php filename
if ( ! function_exists('select_list'))
{
	function select_list($_table,$_id,$_name,$_where='', $_order='',$_attributes='',$defaultvalue='')
	{	
		$sql = "select $_id as id,$_name as name from $_table";
		if ($_where!=''){
			$_where = " where 1=1 and $_where"; 
		}		
		if ($_order!=''){
			$_order = " order by $_order"; 
		}
		$sql = $sql . $_where  . $_order;		
		$userdb =& get_instance();
		$userdb->load->database();
        $query = $userdb->db->query($sql);
		$_list = $query->result();
		$_html='<select ' . $_attributes . ' >';
		$_selected = '';
    foreach($_list as $item)
		{					
		if($item->id ==$defaultvalue) $_selected='selected="selected"'; else $_selected='';					
		$_html = $_html.'<option value="'. $item->id.'"' . $_selected .'>' . $item->name  .'</option>';
		}
		$_html.='</select>';
	return  $_html;
	}

}









